# 需求编程
'''
i.定义了一个学生类：属性:学号，姓名，年龄，性别，身高，体重，成绩，家庭地址，电话号码。行为：学习（要求参数传入学习的时间），玩游戏（要求参数传入游戏名），编程（要求参数传入写代码的行数），数的求和（要求参数用变长参数来做，返回求和结果）
'''


# 创建一个学生类
class Student(object):
    id = ''
    name = ''
    age = 0
    gender = ''
    height = 0
    weight = 0
    score = 0
    address = ''
    mobile = ''

    def study(self, hours):
        print(self.name, '学习了', hours, '小时')

    def play_game(self, game_nama):
        print(self.name, '正在玩名为', game_nama, '的游戏')

    def programming(self, programming_nam):
        print(self.name, '正在编程，已经编写了', programming_nam, '行了')

    def sum(self, a, b):
        return a + b


s = Student()
s.id = '101'
s.age = 20
s.name = '张三'
s.height = 175
s.weight = 50
s.score = 512
s.address = '河南'
s.mobile = '110'
s.study(5)
s.play_game('英雄联盟')
s.programming(50)
print(s.sum(1, 2))

'''
ii.车类：属性：车型号，车轮数，车身颜色，车重量，油箱存储大小 。功能：跑（要求参数传入车的具体功能，比如越野，赛车）
创建：法拉利，宝马，铃木，五菱，拖拉机对象
'''


# 创建车类
class Car:
    model = ''
    wheels_num = 0
    color = ''
    weight = 0.0
    fuel_tank_size = 0

    def run(self, function):
        print('一辆', self.color, '色的', self.model, '在', function)


c = Car()
c.model = '法拉利'
c.wheels_num = 4
c.color = '蓝'
c.weight = 5
c.fuel_tank_size = 2
c.run('推土')

c.model = '宝马'
c.wheels_num = 4
c.color = '红'
c.weight = 5
c.fuel_tank_size = 2
c.run('拉货')

c.model = '铃木'
c.wheels_num = 4
c.color = '绿'
c.weight = 5
c.fuel_tank_size = 2
c.run('赛车')

c.model = '五菱'
c.wheels_num = 4
c.color = '灰'
c.weight = 5
c.fuel_tank_size = 2
c.run('赛车')

c.model = '拖拉机'
c.wheels_num = 4
c.color = '黑'
c.weight = 5
c.fuel_tank_size = 3
c.run('飞车')

'''
iii.笔记本：属性：型号，待机时间，颜色，重量，cpu型号，内存大小，硬盘大小。  行为：打游戏（传入游戏的名称）,办公。
'''


# 创建笔记本类
class Laptop:
    model = ''
    standby_time = 0.0
    color = ''
    weight = 0.0
    cpu_model = ''
    memory_size = 0
    disk_size = 0

    def game(self, game_name):
        print('一台', self.color, '色', self.model, '电脑正在玩', game_name, '这款游戏')

    def office(self):
        print('一台', self.color, '色', self.model, '电脑在办公')


l = Laptop()
l.model = '联想'
l.standby_time = 8.0
l.color = '银'
l.weight = 295
l.cpu_model = '13代i7'
memory_size = 16
disk_size = 1024

l.office()
l.game('王者荣耀')

'''
iv.猴子类：属性：类别，性别，身体颜色，体重。行为：造火（要求传入造火的材料：比如木棍还是石头），学习事物（要求参数传入学习的具体事物，可以不止学习一种事物）
'''


# 创建猴子类
class Monkey:
    category = ''
    gender = ''
    color = ''
    weight = 0

    def make_fire(self, material):
        print('一只', self.gender, self.category, '正在使用', material, '造火')

    def study(self, things):
        print('一只', self.gender, self.category, '正在学习', things)


m = Monkey()
m.category = '黑猩猩'
m.gender = '雄性'
m.color = '黑'
m.weight = 50
m.make_fire('木棍')
m.study('烧火')

# 打电话业务逻辑
'''
人类：
属性:姓名，性别，年龄，所拥有的手机剩余话费，手机品牌，手机电池容量，手机屏幕大小，手机最大待机时长，所拥有的积分。
功能：
发短信（要求参数传入短信内容）。
打电话（要求传入要打的电话号码和要打的时间长度。程序里判断号码是否为空或者本人的话费是否小于1元，若为空或者小于1元则报相对应的错误信息，否则的话拨通。
结束后，按照时间长度扣费并返回扣费（0~10分钟：1元/钟、15个积分/钟，10~20分钟：0.8元/钟、39个积分/钟，其他：0.65元/钟、48个积分/钟））
'''


# 创建一个人类
class Person(object):
    def __init__(self, name, gender, age, phone_calls, phone, battery_capacity, screen_size, standby_time, points):
        self.name = name
        self.gender = gender
        self.age = age
        self.phone_calls = phone_calls
        self.phone = phone
        self.battery_capacity = battery_capacity
        self.screen_size = screen_size
        self.standby_time = standby_time
        self.points = points

    def texting(self, text):
        print(self.name, '正在发短信，短信内容为:', text)

    def call(self, phone_mobile, time):
        if len(str(phone_mobile)) == 0:
            print('号码为空')
        elif self.phone_calls < 1:
            print('话费余额低于1元')
        else:
            print('拨打成功')
            if 0 < time < 10:
                self.phone_calls = self.phone_calls - time
                self.points = self.points + 15 * time
            elif 10 < time < 20:
                self.phone_calls = self.phone_calls - 0.8 * time
                self.points = self.points + 39 * time
            else:
                self.phone_calls = self.phone_calls - 0.65 * time
                self.points = self.points + 48 * time
            print('通话结束,剩余话费：', self.phone_calls, '现有积分：', self.points)


p = Person('张三', '男', 35, 50, 'HUAWEI', 4500, 12.6, 24, 500)
p.texting('你好，你在干什么？')
p.call(150, 12)
p.call('', 10)
p.call('110', 2)
